<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>电路测试 :: 计算机组成原理实验指导</title>
    <meta name="generator" content="Antora 3.2.0-alpha.8">
    <link rel="stylesheet" href="../../_/css/site.css">
<!--    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script> -->
  </head>
  <body class="article">
<header class="header">
  <nav class="navbar">
    <div class="navbar-brand">
      <a class="navbar-item" href="../..">计算机组成原理实验指导</a>
      <button class="navbar-burger" aria-controls="topbar-nav" aria-expanded="false" aria-label="Toggle main menu">
        <span></span>
        <span></span>
        <span></span>
      </button>
    </div>
    <div id="topbar-nav" class="navbar-menu">
      <div class="navbar-end">

        <div class="navbar-item">
          <span class="control">
            <a class="button is-primary" href="https://gitee.com/fpga-lab/digisimlab-open" target="_blank">Download</a>
          </span>
        </div>
      </div>
    </div>
  </nav>
</header>
<div class="body">
<div class="nav-container" data-component="digisimlab" data-version="1.0">
  <aside class="nav">
    <div class="panels">
<div class="nav-panel-menu is-active" data-panel="menu">
  <nav class="nav-menu">
    <button class="nav-menu-toggle" aria-label="Toggle expand/collapse all" style="display: none"></button>
    <h3 class="title"><a href="index.html">计算机组成原理实验指导</a></h3>
<ul class="nav-list">
  <li class="nav-item" data-depth="0">
<ul class="nav-list">
  <li class="nav-item" data-depth="1">
    <a class="nav-link" href="index.html">前言</a>
  </li>
</ul>
  </li>
  <li class="nav-item" data-depth="0">
    <button class="nav-item-toggle"></button>
    <span class="nav-text">Digital仿真软件使用指南</span>
<ul class="nav-list">
  <li class="nav-item" data-depth="1">
    <a class="nav-link" href="introduce-digitalsim.html">下载与安装</a>
  </li>
  <li class="nav-item" data-depth="1">
    <a class="nav-link" href="ds-getting-started.html">新手入门</a>
  </li>
  <li class="nav-item" data-depth="1">
    <a class="nav-link" href="ds-generate-circuit.html">电路生成</a>
  </li>
  <li class="nav-item is-current-page" data-depth="1">
    <a class="nav-link" href="ds-test-circuit.html">电路测试</a>
  </li>
  <li class="nav-item" data-depth="1">
    <a class="nav-link" href="ds-sim-dff.html">时序电路仿真</a>
  </li>
  <li class="nav-item" data-depth="1">
    <a class="nav-link" href="ds-other-useful.html">几个有用的组件</a>
  </li>
  <li class="nav-item" data-depth="1">
    <a class="nav-link" href="ds-hierarchical-design.html">层次化设计</a>
  </li>
  <li class="nav-item" data-depth="1">
    <a class="nav-link" href="ds-parametric-design.html">参数化设计</a>
  </li>
</ul>
  </li>
  <li class="nav-item" data-depth="0">
<ul class="nav-list">
  <li class="nav-item" data-depth="1">
    <button class="nav-item-toggle"></button>
    <span class="nav-text">基本逻辑电路</span>
<ul class="nav-list">
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="lab/bl-overview.html">概述</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="lab/bl-multiplexer.html">多路选择器实验</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="lab/bl-decoder.html">译码器实验</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="lab/bl-counter.html">计数器实验</a>
  </li>
</ul>
  </li>
  <li class="nav-item" data-depth="1">
    <button class="nav-item-toggle"></button>
    <span class="nav-text">运算电路</span>
<ul class="nav-list">
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="lab/op-add_sub_operation.html">加减运算电路实验</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="lab/op-arithmetic_logic_unit.html">算术逻辑单元实验</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="lab/op-compare.html">比较运算电路实验</a>
  </li>
</ul>
  </li>
  <li class="nav-item" data-depth="1">
    <button class="nav-item-toggle"></button>
    <span class="nav-text">数据通路</span>
<ul class="nav-list">
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="lab/dp-overview.html">概述</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="lab/dp-register_file.html">寄存器堆实验</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="lab/dp-single_cycle_datapath.html">单周期数据通路实验</a>
  </li>
</ul>
  </li>
  <li class="nav-item" data-depth="1">
    <button class="nav-item-toggle"></button>
    <span class="nav-text">存储器</span>
<ul class="nav-list">
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="lab/mem-memory.html">存储器实验</a>
  </li>
</ul>
  </li>
  <li class="nav-item" data-depth="1">
    <button class="nav-item-toggle"></button>
    <span class="nav-text">控制器</span>
<ul class="nav-list">
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="lab/cu-overview.html">概述</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="lab/cu-hardwire_controller-1.html">硬布线控制实验（Ⅰ）</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="lab/cu-hardwire_controller.html">硬布线控制实验（Ⅱ）</a>
  </li>
  <li class="nav-item" data-depth="2">
    <a class="nav-link" href="lab/cu-hardwire_controller-3.html">硬布线控制实验（Ⅲ）</a>
  </li>
</ul>
  </li>
</ul>
  </li>
</ul>
  </nav>
</div>
<div class="nav-panel-explore" data-panel="explore">
  <div class="context">
    <span class="title">计算机组成原理实验指导</span>
    <span class="version">1.0</span>
  </div>
  <ul class="components">
    <li class="component is-current">
      <div class="title"><a href="../index.html">计算机组成原理实验指导</a></div>
      <ul class="versions">
        <li class="version is-latest">
          <a href="../index.html">1.31</a>
        </li>
        <li class="version">
          <a href="../1.2/index.html">1.2</a>
        </li>
        <li class="version">
          <a href="../1.1/index.html">1.1</a>
        </li>
        <li class="version is-current">
          <a href="index.html">1.0</a>
        </li>
      </ul>
    </li>
  </ul>
</div>
    </div>
  </aside>
</div>
<main class="article">
<div class="toolbar" role="navigation">
<button class="nav-toggle"></button>
  <a href="../index.html" class="home-link"></a>
<nav class="breadcrumbs" aria-label="breadcrumbs">
  <ul>
    <li><a href="index.html">计算机组成原理实验指导</a></li>
    <li>Digital仿真软件使用指南</li>
    <li><a href="ds-test-circuit.html">电路测试</a></li>
  </ul>
</nav>
<div class="page-versions">
  <button class="version-menu-toggle" title="Show other versions of page">1.0</button>
  <div class="version-menu">
    <a class="version" href="../ds-test-circuit.html">1.31</a>
    <a class="version" href="../1.2/ds-test-circuit.html">1.2</a>
    <a class="version" href="../1.1/ds-test-circuit.html">1.1</a>
    <a class="version is-current" href="ds-test-circuit.html">1.0</a>
  </div>
</div>
</div>
  <div class="content">
<aside class="toc sidebar" data-title="页内目录" data-levels="2">
  <div class="toc-menu"></div>
</aside>
<article class="doc">
<h1 class="page">电路测试</h1>
<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>除了一步步输入数据进行仿真，Digital仿真软件还支持编写测试用例（test case），自动地对电路施加输入数据、对比输出结果。
测试用例可以直接给出数据，也可以编写程序自动生成测试数据。</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_测试数据"><a class="anchor" href="#_测试数据"></a>测试数据</h2>
<div class="sectionbody">
<div class="paragraph">
<p>以前面的2-4译码器为例，点击菜单项“Components/组件 ➤ Misc./其他 ➤ Test case / 测试用例”，添加一个测试组件。右键点击该测试组件，点击组件属性窗口中的“Edit/编辑”按钮，将<a href="#exa-test-vec">例 1</a>的内容复制到编辑器中。</p>
</div>
<div id="exa-test-vec" class="exampleblock">
<div class="title">例 1. 2-4译码器测试数据</div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre>En A1 A0 Y0 Y1 Y2 Y3

 0 0 0 0 0 0 0
 0 0 1 0 0 0 0
 0 1 0 0 0 0 0
 0 1 1 0 0 0 0
 1 0 0 1 0 0 0
 1 0 1 0 1 0 0
 1 1 0 0 0 1 0
 1 1 1 1 0 0 1</pre>
</div>
</div>
</div>
</div>
<div class="paragraph">
<p><a href="#exa-test-vec">例 1</a>中第一行是电路的输入输出引脚的名称（即“Label/标签”属性），后面各行是测试数据，每一列与第一行的引脚对应。</p>
</div>
<div class="paragraph">
<p>点击菜单项“Simulation/仿真 ➤ Run Tests / 运行测试用例”或对应工具条按钮，弹出“Test result /测试结果”窗口。输出引脚的数据如果与预期相符，则以绿底色显示；如果不相符，则以红底色显示，并且同时给出预期值和测试值的对比。</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="注"></i>
</td>
<td class="content">
<div class="paragraph">
<p><a href="#exa-test-vec">例 1</a>的最后一行测试数据有意植入了错误，所以仿真结果会有一处红底色显示。</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>在“Test result /测试结果”窗口中点击菜单项“File/文件 ➤ Save Data / 保存数据”，测试结果数据将被保存为CSV文件。该文件可通过WPS等办公软件打开，用于实验报告的实验结果分析。</p>
</div>
<div class="paragraph">
<p>测试结果也能够以图形的方式显示，点击菜单项“View/视图 ➤ Show graph / 显示图”即可打开图形窗口。</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_测试程序"><a class="anchor" href="#_测试程序"></a>测试程序</h2>
<div class="sectionbody">
<div class="paragraph">
<p>除了直接给出测试数据，编辑器中也可以编写测试程序，<a href="#exa-test-code">例 2</a>给出了2-4译码器的测试程序。</p>
</div>
<div id="exa-test-code" class="exampleblock">
<div class="title">例 2. 2-4译码器测试程序</div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre>En A1 A0 Y3 Y2 Y1 Y0

repeat(4)  0  bits(2, n) bits(4, 0)
repeat(4)  1  bits(2, n) bits(4, 1&lt;&lt;n)</pre>
</div>
</div>
</div>
</div>
<div class="paragraph">
<p>有关测试程序的语句、语法等详细介绍，请点击编辑器窗口的“帮助”按钮。</p>
</div>
<div class="sidebarblock text-center">
<div class="content">
<div class="title">许可 | License</div>
<div class="paragraph">
<p><a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">CC BY-NC-SA：署名-非商业性使用-相同方式共享 4.0 国际许可协议</a></p>
</div>
<div class="paragraph">
<p>作者：
肖铁军 &lt;<a href="mailto:xiaotiejun@foxmail.com.cn">xiaotiejun@foxmail.com.cn</a>&gt;</p>
</div>
</div>
</div>
</div>
</div>
</article>
  </div>
</main>
</div>
<footer class="footer">
  <p>This page was built using the Antora default UI.</p>
  <p>The source code for this UI is licensed under the terms of the MPL-2.0 license.</p>
</footer>
<script id="site-script" src="../../_/js/site.js" data-ui-root-path="../../_"></script>
<script async src="../../_/js/vendor/highlight.js"></script>
  </body>
</html>
